package com.meisupic.copyright.support;

import com.meisupic.copyright.common.WorksProcessDetailEnum;
import com.meisupic.copyright.domain.po.CopyRightWorks;
import com.meisupic.copyright.domain.vo.WorksAuditVo;
import com.meisupic.copyright.repo.CopyRightWorksRepo;
import com.meisupic.copyright.service.ICopyRightWorksService;
import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @Author lanjian
 * @Date 2018/5/12 下午4:24
 */
@Component
public class FailTaskJob {

  @Autowired
  ICopyRightWorksService copyRightWorksService;

  @Autowired
  CopyRightWorksRepo copyRightWorksRepo;

  private Logger logger = LoggerFactory.getLogger(this.getClass());

  public void executeUnSuccessWorks(){

    CopyRightWorks copyRightWorks = new CopyRightWorks();
    copyRightWorks.setWorksProcessDetail(WorksProcessDetailEnum.preCpcc);
    List<CopyRightWorks> preAuditWorks = copyRightWorksRepo.findAll(Example.of(copyRightWorks));
    logger.info("查询到{}个需要执行审核的作品",preAuditWorks.size());
    for (CopyRightWorks preAuditWork : preAuditWorks) {
      WorksAuditVo worksAuditVo = new WorksAuditVo();
      worksAuditVo.setId(preAuditWork.getId());
      worksAuditVo.setAuditor("");
      copyRightWorksService.doPass(worksAuditVo);
    }
  }

}
